/*----------------------------------------------------------------------
  - File name      : STC8Ax_DELAY.c
  - Author         : Quark Team
  - Update date    : 2020-11-25                 
  -	Copyright      : Gevico Electronic studio   
  - Module comments: Layout module.
-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/

#include "STC8Ax_DELAY.h"
#include "intrins.h"

/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/

extern uint32 SYSCLK_FRE;
static vuint16 MS_Count = 0;

/*-----------------------------------------------------------------------
|                               FUNCTION                                |
-----------------------------------------------------------------------*/

/*--------------------------------------------------------
| @Description: MCU delay ms function                    |
| @param      : None                                     |
| @return     : FSCSTATE : Success / Fail                |
--------------------------------------------------------*/

FSCSTATE Delay_init(void)
{
	MS_Count = SYSCLK_FRE / DELAY_COUNT;
	return FSC_SUCCESS;
}

/*--------------------------------------------------------
| @Description: MCU power on stability delay function    |
| @param      : None                                     |
| @return     : FSCSTATE : Success / Fail                |
--------------------------------------------------------*/

FSCSTATE Delay_Pos(void) 
{	
	uint16 i = 1000;
	for(; i>0; i--) ;
	return FSC_SUCCESS;
}

/*--------------------------------------------------------
| @Description: MCU delay ms function                    |
| @param      : uint16 nms                               |
| @return     : None                                     |
--------------------------------------------------------*/

void Delay_ms(uint16 nms)
{
	uint16 i;
	
	 for(; nms>0; nms--)
	 {			
		 i = MS_Count;
		 while(--i);
	 }
}


/*-----------------------------------------------------------------------
|          END OF FLIE        (C) COPYRIGHT Gevico Electronics          | 
-----------------------------------------------------------------------*/



